class Admin::BaseController < ApplicationController
  include AuthenticatedAdmin
  
  before_filter :login_required, :except => ["login", "signup"]

  layout :set_layout
  
  def set_layout
    if params[:controller] == "admin/admin" && params[:action] == "login"
      return "admin/login"
    else
      return "admin/default"
    end
  end
  
  def os_family
    case RUBY_PLATFORM
      when /ix/i, /ux/i, /gnu/i, /sysv/i, /solaris/i, /sunos/i, /bsd/i  
        "Unix"  
      when /win/i, /ming/i  
        "WinNT"  
    else  
        "Other"  
    end
  end
  
  def browser_type
    system_data
    return session[:info][:browser_type]  
  end  
  
  def browser_version
    system_data
    return session[:info][:browser_version]  
  end  
  
  def platform_type
    system_data
    return session[:info][:platform]  
  end  
  
  def index
    @os = platform_type
  end
  
  protected  
  def system_data  
    if session[:info].blank?
      info = Info.new(request.env)  
      session[:info] = {}  
      session[:info][:browser_type] = info.browser[:type]  
      session[:info][:browser_version] = info.browser[:version]  
      session[:info][:platform] = info.platform  
    end  
  end    
  
end
